<?php
class Adminsessions extends CI_Model {

	function __construct()
	{
		parent::__construct();
		$this->load->model('process_data');
	}
	
	function getSessionId()
	{
		return $this->session->userdata('session_id');
	}
	
	function getSessionEmail()
	{
		return $this->session->userdata('admin_email');
	}
	
	function getSessionUserId()
	{
		return $this->session->userdata('admin_user_id');
	}
	
	function logOut(){
		$this->session->sess_destroy();
	}
	
	function isLogedIn(){
			if($this->session->userdata('admin_email') != null && $this->session->userdata('admin_logged_in') === TRUE){
				return TRUE;
			}else {
				return FALSE;
			}
	}
	
	function firstName(){
		$rs = $this->process_data->usersFullDetails($this->getSessionEmail());
		if(count($rs)>0){
			return $rs[0]['first_name'];
		}
	}
	
	function userDetails(){
		$rs = $this->process_data->usersFullDetails($this->getSessionEmail());
		if(count($rs)>0){
			return $rs[0]['first_name'];
		}
	}
	
	function setSessionData($emailId, $userId,  $userType){
		$userSessionData = array(
                	'admin_email'     => $emailId,
					'admin_user_id'	=> $userId,
                	'admin_logged_in' => TRUE,
					'admin_user_type' => $userType
        );

		$this->session->set_userdata($userSessionData);
	}
}

?>